package net.wofly.sale.stock.service.impl;

import net.wofly.sale.report.domain.OutStockDTO;
import net.wofly.sale.stock.domain.OutStock;
import net.wofly.sale.stock.repository.OutStockRepository;
import net.wofly.sale.stock.service.IOutStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service("iOutStockService")
@Transactional
public class OutStockServiceImpl implements IOutStockService {
    
    @Autowired
    OutStockRepository outStockRepository;
    
    @Override
    public OutStock save(OutStock entity) {
        return outStockRepository.save(entity);
    }
    
    @Override
    public void delete(OutStock entity) {
        outStockRepository.delete(entity);
    }
    
    @Override
    public void delete(String key) {
        outStockRepository.delete(key);
    }
    
    @Override
    public OutStock findOne(String key) {
        return outStockRepository.findOne(key);
    }
    
    @Override
    public OutStock findByProofID(String proofID) {
        return outStockRepository.findByProofID(proofID);
    }
    
    @Override
    public Page<OutStock> findAll(Specification specification, Pageable pageable) {
        return outStockRepository.findAll(specification, pageable);
    }
    
    @Override
    public List<OutStock> save(List<OutStock> entityList) {
        return (List<OutStock>) outStockRepository.save(entityList);
    }

    @Override
    public List<OutStockDTO> findByCountDate(Long countDate, Long countEndTime) {
        return outStockRepository.findByCountDate(countDate, countEndTime);
    }
}
